package cn.yikaojiuguo.student.ui.global;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import cn.yikaojiuguo.student.R;
import cn.yikaojiuguo.student.support.utils.ToastUtil;
import cn.yikaojiuguo.student.support.utils.Util;
import cn.yikaojiuguo.student.ui.base.BasePopupWindow;

/**
 * Created by cfan_yang on 2015/12/9.
 */
public class SocialLoginPopupWindow extends BasePopupWindow implements View.OnClickListener{

    private LinearLayout ll_qq;
    private LinearLayout ll_wx;
    private LinearLayout ll_wb;
    /**
     * 初始化PopupWindow
     *
     * @param context
     * @param widthPercent  PopupWindow宽度占屏幕百分比
     * @param heightPercent PopupWindow高度占屏幕百分比
     */
    public SocialLoginPopupWindow(Activity context, float widthPercent, float heightPercent) {
        super(context, widthPercent, heightPercent);
    }

    @Override
    protected void initEvent() {
        ll_qq.setOnClickListener(this);
        ll_wx.setOnClickListener(this);
        ll_wb.setOnClickListener(this);
    }

    @Override
    protected void initView(Context context) {
        ll_qq = (LinearLayout) mConvertView.findViewById(R.id.ll_qq);
        ll_wx = (LinearLayout) mConvertView.findViewById(R.id.ll_wx);
        ll_wb = (LinearLayout) mConvertView.findViewById(R.id.ll_wb);
    }

    @Override
    protected int getLayoutResourceId() {
        return R.layout.layout_popup_social_login;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ll_qq:
                ToastUtil.showToast(mContext, "qq");
                break;
            case R.id.ll_wx:
                ToastUtil.showToast(mContext, "wx");
                break;
            case R.id.ll_wb:
                ToastUtil.showToast(mContext, "wb");
                break;
        }
    }

    @Override
    public void dismiss() {
        super.dismiss();
        Util.lightOn((Activity) mContext);
    }

    @Override
    public void showAtLocation(View parent, int gravity, int x, int y) {
        super.showAtLocation(parent, gravity, x, y);
        Util.lightOff((Activity) mContext);
    }
}
